#ifndef __NOISEGATE_H__
#define __NOISEGATE_H__

#include "AnalogFilter.h"

#define REALTYPE float
#define CLOSED  1
#define OPENING 2
#define OPEN    3
#define CLOSING 4
#define ENV_TR 0.0001f

class Gate
{
private:
	unsigned int SAMPLE_RATE;
	int PERIOD;
public:

  Gate (REALTYPE * efxoutl_, REALTYPE * efxoutr_);
  ~Gate ();

  void out (REALTYPE * smps_l, REALTYPE * smps_r);

  void Gate_Change (int np, int value);
  void Gate_Change_Preset (int npreset);
  void cleanup ();
  int getpar (int npar);

  REALTYPE *efxoutl;
  REALTYPE *efxoutr;



  // Compressor

  int Pthreshold;		// attack time  (ms)
  int Pattack;			// release time (ms)
  int Ohold;
  int Pdecay;
  int Prange;
  int Plpf;
  int Phpf;
  int Phold;

private:

  int hold_count;
  int state;
  float range;
  float cut;
  float t_level;
  float a_rate;
  float d_rate;
  float env;
  float gate;
  float fs;
  float hold;

  void setlpf (int Plpf);
  void sethpf (int Phpf);


  AnalogFilter *lpfl, *lpfr, *hpfl, *hpfr;
public:
	bool SetSampleRate(unsigned int iSamplePerSec);
	bool SetBufferSize(int nSamples);

};

#endif
